import {create} from 'zustand';

export interface DataItem {
  id: string;
  title: string;
  desc: string;
  star: number;
  paragraph: string;
  author: string;
  isSave: boolean;
}

export interface FlatListDataStore {
  data1: DataItem[];
  data2: DataItem[];
}

export interface FlatListDataStoreState extends FlatListDataStore {
  setStore<K extends keyof FlatListDataStore>(
    key: K,
    value: FlatListDataStore[K],
  ): void;
}

const useFlatListStore = create<FlatListDataStoreState>(set => ({
  data1: [],
  data2: [],
  setStore: (key, value) => set({[key]: value}),
}));

export {useFlatListStore};
